package com.copa.l2309;

import java.util.HashSet;
import java.util.Set;

/**
 * @author copa
 * @createDate 2023-01-27 9:45
 * @function 哈希表法
 */
public class Test1 {

    public String greatestLetter(String s) {
        if (1 == s.length()) {
            return "";
        }
        Set<Character> set = new HashSet<>();
        char[] charArray = s.toCharArray();
        for (char c : charArray) {
            set.add(c);
        }
        for (int i = 25; i >= 0; i--) {
            if (set.contains((char)('A' + i)) && set.contains((char)('a' + i))) {
                return String.valueOf((char)('A' + i));
            }
        }
        return "";
    }

    public static void main(String[] args) {
        String s = "nzmguNAEtJHkQaWDVSKxRCUivXpGLBcsjeobYPFwTZqrhlyOIfdM";
        System.out.println(new Test1().greatestLetter(s));
    }
}
